<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="​        买的中景园电子的lcd显示屏，基本信息如下所示：       ST7796初始化命令： 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778">
<meta property="og:type" content="article">
<meta property="og:title" content="lcd屏幕驱动IC ST7796">
<meta property="og:url" content="http://example.com/2024/01/14/lcd%E5%B1%8F%E5%B9%95%E9%A9%B1%E5%8A%A8IC%20ST7796/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="​        买的中景园电子的lcd显示屏，基本信息如下所示：       ST7796初始化命令： 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131304042.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131305628.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131307919.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401141518323.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401141519616.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401141525325.jpg">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401142018943.png">
<meta property="og:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401142036257.jpg">
<meta property="article:published_time" content="2024-01-14T12:07:07.000Z">
<meta property="article:modified_time" content="2024-01-14T12:07:07.000Z">
<meta property="article:author" content="xudonglei">
<meta property="article:tag" content="显示屏">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131304042.png">

<link rel="canonical" href="http://example.com/2024/01/14/lcd%E5%B1%8F%E5%B9%95%E9%A9%B1%E5%8A%A8IC%20ST7796/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>lcd屏幕驱动IC ST7796 | 学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2024/01/14/lcd%E5%B1%8F%E5%B9%95%E9%A9%B1%E5%8A%A8IC%20ST7796/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          lcd屏幕驱动IC ST7796
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-01-14 20:07:07" itemprop="dateCreated datePublished" datetime="2024-01-14T20:07:07+08:00">2024-01-14</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2024/01/14/lcd%E5%B1%8F%E5%B9%95%E9%A9%B1%E5%8A%A8IC%20ST7796/" class="post-meta-item leancloud_visitors" data-flag-title="lcd屏幕驱动IC ST7796" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2024/01/14/lcd%E5%B1%8F%E5%B9%95%E9%A9%B1%E5%8A%A8IC%20ST7796/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2024/01/14/lcd%E5%B1%8F%E5%B9%95%E9%A9%B1%E5%8A%A8IC%20ST7796/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>​        买的中景园电子的lcd显示屏，基本信息如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131304042.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131305628.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401131307919.png" style="zoom:67%;">

<p><strong>ST7796初始化命令：</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br></pre></td><td class="code"><pre><span class="line">lcd_send_cmd( <span class="number">0xF0</span> );         <span class="comment">// Command Set Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x96</span>                      <span class="comment">// enable command 2 part II                </span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0x36</span> );         <span class="comment">// Memory Data Access Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x28</span>                      <span class="comment">//横屏</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0x3A</span> );         <span class="comment">//设置颜色格式为RGB565</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x55</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xB4</span> );         <span class="comment">//Display Inversion Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x01</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xB1</span> );        <span class="comment">//Frame Rate Control (In Normal Mode/Full Colors)</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x80</span>,<span class="number">0x10</span></span><br><span class="line">&#125;, <span class="number">2</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xB5</span> );       <span class="comment">//Blanking Porch Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x1F</span>,<span class="number">0x50</span>,<span class="number">0x00</span>,<span class="number">0x20</span></span><br><span class="line">&#125;, <span class="number">4</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xB6</span> );       <span class="comment">// Display Function Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x8A</span>,<span class="number">0x07</span>,<span class="number">0x3B</span></span><br><span class="line">&#125;, <span class="number">3</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xC0</span> );       <span class="comment">// Power Control 1</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x80</span>,<span class="number">0x64</span></span><br><span class="line">&#125;, <span class="number">2</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xC1</span> );       <span class="comment">// Power Control 2</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x13</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xC2</span> );       <span class="comment">// Power Control 3</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0xA7</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xC5</span> );       <span class="comment">// VCOM Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x09</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xE8</span> );       <span class="comment">//Display Output Ctrl Adjust</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x40</span>,<span class="number">0x8a</span>,<span class="number">0x00</span>,<span class="number">0x00</span>,<span class="number">0x29</span>,<span class="number">0x19</span>,<span class="number">0xA5</span>,<span class="number">0x33</span></span><br><span class="line">&#125;, <span class="number">8</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xE0</span> );       <span class="comment">//Positive Gamma Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0xF0</span>,<span class="number">0x06</span>,<span class="number">0x0B</span>,<span class="number">0x07</span>,<span class="number">0x06</span>,<span class="number">0x05</span>,<span class="number">0x2E</span>,<span class="number">0x33</span>,<span class="number">0x47</span>,<span class="number">0x3A</span>,<span class="number">0x17</span>,<span class="number">0x16</span>,<span class="number">0x2E</span>,<span class="number">0x31</span></span><br><span class="line">&#125;, <span class="number">14</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xE1</span> );       <span class="comment">// Negative Gamma Control</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0xF0</span>,<span class="number">0x09</span>,<span class="number">0x0D</span>,<span class="number">0x09</span>,<span class="number">0x08</span>,<span class="number">0x23</span>,<span class="number">0x2E</span>,<span class="number">0x33</span>,<span class="number">0x46</span>,<span class="number">0x38</span>,<span class="number">0x13</span>,<span class="number">0x13</span>,<span class="number">0x2C</span>,<span class="number">0x32</span></span><br><span class="line">&#125;, <span class="number">14</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xF0</span> );</span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x3C</span>                     <span class="comment">// disable command 2 part I</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0xF0</span> );</span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x69</span>                     <span class="comment">// disable command 2 part II</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0x35</span> );        <span class="comment">// Tearing Effect Line On</span></span><br><span class="line">lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">&#123;</span><br><span class="line">    <span class="number">0x00</span></span><br><span class="line">&#125;, <span class="number">1</span> );</span><br><span class="line"></span><br><span class="line">lcd_send_cmd( <span class="number">0x21</span> );       <span class="comment">// Display Inversion On</span></span><br><span class="line">lcd_send_cmd( <span class="number">0x11</span> );       <span class="comment">// Sleep Out</span></span><br><span class="line">lcd_send_cmd( <span class="number">0x29</span> );       <span class="comment">// Display On</span></span><br></pre></td></tr></table></figure>
<p><strong>填充一个矩形框代码如下：</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">LCD_Fill</span><span class="params">(u16 xsta,u16 ysta,u16 xend,u16 yend)</span></span></span><br><span class="line"><span class="function"></span>&#123;          </span><br><span class="line">    <span class="keyword">uint8_t</span> tx_data[<span class="number">4</span>];</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* 设置Column地址 */</span></span><br><span class="line">    tx_data[<span class="number">0</span>] = xsta &gt;&gt; <span class="number">8</span>; <span class="comment">//起始地址高8位</span></span><br><span class="line">    tx_data[<span class="number">1</span>] = xsta &amp; <span class="number">0xFF</span>; <span class="comment">//起始地址低8位</span></span><br><span class="line">    tx_data[<span class="number">2</span>] = xend &gt;&gt; <span class="number">8</span>; <span class="comment">//结束地址高8位</span></span><br><span class="line">    tx_data[<span class="number">3</span>] = xend &amp; <span class="number">0xFF</span>; <span class="comment">//结束地址低8位</span></span><br><span class="line">	</span><br><span class="line">    lcd_send_cmd( <span class="number">0x2A</span> );</span><br><span class="line">    lcd_send_data( tx_data, <span class="number">4</span> );</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* 设置row地址 */</span></span><br><span class="line">    tx_data[<span class="number">0</span>] = ysta &gt;&gt; <span class="number">8</span>;</span><br><span class="line">    tx_data[<span class="number">1</span>] = ysta &amp; <span class="number">0xFF</span>;</span><br><span class="line">    tx_data[<span class="number">2</span>] = yend &gt;&gt; <span class="number">8</span>;</span><br><span class="line">    tx_data[<span class="number">3</span>] = yend &amp; <span class="number">0xFF</span>;</span><br><span class="line">	</span><br><span class="line">    lcd_send_cmd( <span class="number">0x2B</span> );</span><br><span class="line">    lcd_send_data( tx_data, <span class="number">4</span> );</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/* 写入图像数据 */</span></span><br><span class="line">    lcd_send_cmd( <span class="number">0x2C</span> );</span><br><span class="line">    GPIO_ResetBits( BSP_LCD_GPIO_PORT, BSP_LCD_CS_GPIO ); <span class="comment">//CS=0</span></span><br><span class="line">    SPI_DataSizeConfig( SPI1, SPI_DataSize_16b );</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">uint16_t</span> i = <span class="number">0</span>; i &lt;( xend - xsta + <span class="number">1</span> ) * ( yend - ysta + <span class="number">1</span> ); i++) </span><br><span class="line">		&#123;</span><br><span class="line">        <span class="keyword">while</span>( SPI_I2S_GetFlagStatus( SPI1, SPI_I2S_FLAG_BSY ) == SET ); <span class="comment">//等待传输完成</span></span><br><span class="line">        SPI_I2S_SendData(SPI1,  <span class="number">0x0000</span>);                 <span class="comment">//用黑色填充</span></span><br><span class="line">    &#125;</span><br><span class="line">    GPIO_SetBits( BSP_LCD_GPIO_PORT, BSP_LCD_CS_GPIO ); <span class="comment">//CS=1    </span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401141518323.png" style="zoom:60%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401141519616.png" style="zoom:60%;">

<p>例子LCD_Fill(80, 80, 300, 100)效果：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401141525325.jpg" style="zoom:30%;">

<p>​        0x2A和0x4B寄存器分别需要设置4个参数，起始地址的高8为，起始地址的低8位。结束地址的高8为，结束地址的低8位。</p>
<p>通过设置这两个寄存器，共同构成了一个矩形坐标区域，就是确定了要在LCD屏幕上显示的区域。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401142018943.png" style="zoom:67%;">

<p>接下来只需要往0x2C寄存器中写入颜色数值，即可在上述区域内显示，写入的第一个颜色值，显示在(xs,ys)坐标处，第2个颜色值显示在(xs+,ys)坐标处。</p>
<p>​        横竖屏切换只要设置MVbit：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">lcd_send_cmd( <span class="number">0x36</span> );         <span class="comment">// Memory Data Access Control</span></span><br><span class="line">   lcd_send_data( ( <span class="keyword">uint8_t</span>[] )</span><br><span class="line">   &#123;</span><br><span class="line">       <span class="number">0x08</span>                      <span class="comment">//竖屏</span></span><br><span class="line">   &#125;, <span class="number">1</span> );</span><br></pre></td></tr></table></figure>
<p>对比下同样的LCD_Fill(80, 80, 300, 100)的效果：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202401142036257.jpg" style="zoom:30%;">

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E6%98%BE%E7%A4%BA%E5%B1%8F/" rel="tag"># 显示屏</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2024/01/11/uint8_t%E6%95%B0%E7%BB%84%E7%B1%BB%E5%9E%8B%E7%9A%84%E5%BA%94%E7%94%A8/" rel="prev" title="uint8_t数组类型的应用">
      <i class="fa fa-chevron-left"></i> uint8_t数组类型的应用
    </a></div>
      <div class="post-nav-item">
    <a href="/2024/01/14/%E8%8A%AF%E7%89%87%E5%86%85%E6%89%A7%E8%A1%8C-XIP%E6%8F%AD%E7%A7%98/" rel="next" title="芯片内执行-XIP揭秘">
      芯片内执行-XIP揭秘 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
